﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AdministracionCooperativa.Formularios;

namespace AdministracionCooperativa
{
    public partial class Form3 : Form
    {
        public void habilitbtn()
        {
            btnco.Enabled = true;
            btncu.Enabled = true;
            btnre.Enabled = true;
            btnad.Enabled = true;
            btncb.Enabled = true;
            btnch.Enabled = true;
           // btnmo.Enabled = true;
            btnso.Enabled = true;
        }
        public void cerrarform()
        {
            if (Application.OpenForms["Frmco"] != null)//si formulario CORTE DEL DIA abierto lo cierra
            {
                Application.OpenForms["Frmco"].Close();
                
            }
            if (Application.OpenForms["formcu"] != null)//si formulario CUOTA abierto lo cierra
            {               
                Application.OpenForms["formcu"].Close();
                
            }
           if (Application.OpenForms["Frmrp"] != null)//si formulario REPORTE abierto lo cierra
                  { Application.OpenForms["Frmrp"].Close(); }
           /* if (Application.OpenForms["Frmmo"] != null)//si formulario MOVIMIENTO abierto lo cierra
                  { Application.OpenForms["Frmmo"].Close(); }*/
            if (Application.OpenForms["Frmch"] != null)//si formulario CHOFER abierto lo cierra
                  { Application.OpenForms["Frmch"].Close(); }
            if (Application.OpenForms["Frmcb"] != null)//si formulario COMBI abierto lo cierra
                  { Application.OpenForms["Frmcb"].Close(); }
            if (Application.OpenForms["Frmso"] != null)//si formulario SOCIO abierto lo cierra
                  { Application.OpenForms["Frmso"].Close(); }
            if (Application.OpenForms["Frmad"] != null)//si formulario ADMINISTRACION abierto lo cierra
            { Application.OpenForms["Frmad"].Close();  }
            if (Application.OpenForms["rptvisor"] != null)//si formulario VISOR DE REPORTES abierto lo cierra
            { Application.OpenForms["rptvisor"].Close(); }
            
        }
        public Form3()
        {
            InitializeComponent();
        }

        private void btnco_Click(object sender, EventArgs e)
        {
            habilitbtn();
            cerrarform();
            btnco.Enabled = false;
            Frmco corte = new Frmco();
            corte.MdiParent = this.MdiParent;
            corte.Show();
        }

        private void btncu_Click(object sender, EventArgs e)
        {
            habilitbtn();
            cerrarform();
            btncu.Enabled = false;
            formcu cuota = new formcu();
            cuota.MdiParent = this.MdiParent;
            cuota.Show();
        }

        private void btnre_Click(object sender, EventArgs e)
        {
            habilitbtn();
            cerrarform();
            btnre.Enabled = false;
            Frmrp reporte = new Frmrp();
            reporte.MdiParent = this.MdiParent;
            reporte.Show();
        }

        private void btnmo_Click(object sender, EventArgs e)
        {
            habilitbtn();
            cerrarform();
            //btnmo.Enabled = false;
            Frmmo movi = new Frmmo();
            movi.MdiParent = this.MdiParent;
            movi.Show();
        }

        private void btnch_Click(object sender, EventArgs e)
        {
            habilitbtn();
            cerrarform();
            btnch.Enabled = false;
            Frmch chofer = new Frmch();
            chofer.MdiParent = this.MdiParent;
            chofer.Show();
        }

        private void btncb_Click(object sender, EventArgs e)
        {
            habilitbtn();
            cerrarform();
            btncb.Enabled = false;
            Frmcb combi = new Frmcb();
            combi.MdiParent = this.MdiParent;
            combi.Show();
        }

        private void btnso_Click(object sender, EventArgs e)
        {
            habilitbtn();
            cerrarform();
            btnso.Enabled = false;
            Frmso socio = new Frmso();
            socio.MdiParent = this.MdiParent;
            socio.Show();
        }

        private void btnad_Click(object sender, EventArgs e)
        {
            habilitbtn();
            cerrarform();
            btnad.Enabled = false;
            Frmad admi = new Frmad();
            admi.MdiParent = this.MdiParent;
            admi.Show();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}
